# coding=utf-8
# blog.models.py
import uuid
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone


def pk_generator():
    return str(uuid.uuid4()).replace('-', '').lower()



class Posts(models.Model):
    seed = models.CharField(_('seed'), max_length=40, default=pk_generator)
    title = models.CharField(_('title'), max_length=200)
    author = models.ForeignKey('authentication.User', to_field='username')
    excerpt = models.TextField(_('excerpt'))
    content = models.TextField(_('content'))
    password = models.CharField(_('password'), max_length=20, blank=True)
    create_datetime = models.DateTimeField(_('create time'), auto_now_add=True, default=timezone.now)
    update_datetime = models.DateTimeField(_('update time'), auto_now=True, blank=True, null=True, default=timezone.now)

